var eamineeId;
$(document).ready(function(){
	eamineeId = window.sessionStorage.getItem("eamineeId");
	if(!eamineeId)
		window.location.href = "findAdmissionTicket.html";
	
	$.ajax({
		type:'GET',
		cache:false,
		url:rootPath+"/selectTicket",
		async:true,
		data:{
			eamineeId:eamineeId
		},
		success:function(result)
		{
			var examineNumber = result.extend.Ticket[0].examineNumber;//考生信息
			var name = result.extend.Ticket[0].name;
			var gender = result.extend.Ticket[0].gender;
			var cardId = result.extend.Ticket[0].cardId;
			var studentNumber = result.extend.Ticket[0].studentNumber;
			var image = result.extend.Ticket[0].image;
			
			document.getElementById("examineNumber").innerHTML = examineNumber;
			document.getElementById("eamineeId").innerHTML = eamineeId;
			document.getElementById("name").innerHTML = name;
			document.getElementById("gender").innerHTML = gender;
			document.getElementById("cardId").innerHTML = cardId;
			document.getElementById("studentNumber").innerHTML = studentNumber;
			
			var curWwwPath=window.document.location.href;
			var pathName=window.document.location.pathname;
			var pos=curWwwPath.indexOf(pathName);
			var localhostPaht=curWwwPath.substring(0,pos);
			document.getElementById("image").innerHTML = "<img src='" + rootPath + "/" + image + "' />";
			
			var ticket = result.extend.Ticket;//考试信息
			var examinationTableString = "<tr><td style='width: 90px;font-size: 17px;padding: 5px 0px 0px 0px;'>考试时间</td><td style='width: 60px;font-size: 17px;padding: 5px 0px 0px 0px;'>考试科目</td><td style='width: 220px;font-size: 17px;padding: 5px 0px 0px 0px;'>考点、考场</td></tr>";
			/*for(var i=0;i<ticket.length;i++)
			{
				examinationTableString += "<tr><td>" + ticket[i].examinationTime +"<br>时长"+ ticket[i].testTime + "</td><td style='font-size: 16px;'>" + ticket[i].overall + "</td><td style='padding: 0px 25px;'>" + ticket[i].examinationPlace +" "+ ticket[i].examinationRoom + "</td></tr>";
			}*/
			//document.getElementById("examinationTable").innerHTML = examinationTableString;
			
			var date1 = ticket[0].testTime;
			var date2 = ticket[1].testTime;
			
			if(date1.length < date2.length)
			{
				examinationTableString += "<tr><td style='text-align: left;'>" + ticket[1].examinationTime +"<br>"+ ticket[1].testTime + "</td><td>" + "文化基础<br/>水平测试" + "</td><td style='padding: 0px 25px;text-align: left;'>" + ticket[1].examinationPlace +"<br/>第"+ ticket[1].examinationRoom + "考场</td></tr>";
				
				examinationTableString += "<tr><td style='text-align: left;'>" + ticket[0].examinationTime +"<br>"+ ticket[0].testTime + "</td><td>" + "综合素质<br/>测       试" + "</td><td style='padding: 0px 25px;text-align: left;'>" + ticket[0].examinationPlace +"<br/>"+ ticket[0].examinationRoom + "</td></tr>";
			}
			else
			{
				examinationTableString += "<tr><td style='text-align: left;'>" + ticket[0].examinationTime +"<br>"+ ticket[0].testTime + "</td><td>" + "文化基础<br/>水平测试" + "</td><td style='padding: 0px 25px;text-align: left;'>" + ticket[0].examinationPlace +"<br/>第"+ ticket[0].examinationRoom + "考场</td></tr>";
				
				examinationTableString += "<tr><td style='text-align: left;'>" + ticket[1].examinationTime +"<br>"+ ticket[1].testTime + "</td><td>" + "综合素质<br/>测       试" + "</td><td style='padding: 0px 25px;text-align: left;'>" + ticket[1].examinationPlace +"<br/>"+ ticket[1].examinationRoom + "</td></tr>";
			}
			
			$("#examinationTable").html(examinationTableString);
		}
	});
});

function download2()
{
	window.location.href = rootPath + "/ProducePDF?eamineeId=" + eamineeId;
	/*$.ajax({
		type:'GET',
		cache:false,
		url:rootPath+"/getTime2",
		async:true,
		success:function(result)
		{
			if( result.code == "100" )
				window.location.href = rootPath + "/ProducePDF?eamineeId=" + eamineeId;
			else
				alert(result.extend.code);
		}
	});*/
	
}

function print2()
{
	updateTicketType();
	window.print();
	/*$.ajax({
		type:'GET',
		cache:false,
		url:rootPath+"/getTime2",
		async:true,
		success:function(result)
		{
			if( result.code == "100" )
				window.print();
			else
				alert(result.extend.code);
		}
	});*/
}

function updateTicketType()
{
	$.ajax({
		type:'GET',
		cache:false,
		url:rootPath+"/updateTicketType",
		async:true,
		data:{
			eamineeId:eamineeId
		}
	});
}

function logout()
{
	window.sessionStorage.clear();
	window.location.href = "findAdmissionTicket.html";
}